<?php

class Ebx_HelperBroker {

	protected static $_helpers = array();

	static function getHelper($helper) {
		if (isset(self::$_helpers[$helper])) {
			return self::$_helpers[$helper];
		}

		$helperClass = self::getFullClassName($helper);
		self::$_helpers[$helper] = new $helperClass();

		return self::$_helpers[$helper];
	}

	static function getFullClassName($name) {
		$name = ucfirst($name);
		return 'Ebx_Helper_'.$name;
	}

	static function helper($helper, $value = null, $options = null) {
		$helper = self::getHelper($helper);
		if (is_callable(array($helper, 'setOptions'))) {
			$helper->setOptions($options);
			return $helper->direct($value);
		} else {
			return $helper->direct($value, $options);
		}

	}

}

?>